// 1.4 创建store
import { TypedUseSelectorHook, useSelector } from 'react-redux';
import { createStore } from 'redux';
import rootReducer from './reducer';

const store = createStore(rootReducer);
export default store;

// 2.1. stror/index.ts中定义RootState类型 提取getState函数的返回值

// 3.1 去官网拿官方封装过的RootState和useAppSelector
export type RootState = ReturnType<typeof store.getState>;
// Inferred type: {posts: PostsState, comments: CommentsState, users: UsersState}
// export type AppDispatch = typeof store.dispatch;
export const useAppSelector: TypedUseSelectorHook<RootState> = useSelector;
